



package wviz.gui.graph;

/**
 * Create a class of term T with score S.
 * <p/>
 *
 * @author Mohammad Asgari
 * @version 1.0
 * @date 13-Jan-2009
 */
public class ScoredTerm<T, S> {
    private final T term;
    private final S score;

    public ScoredTerm(T term, S score) {
        this.term = term;
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ScoredTerm that = (ScoredTerm) o;

        if (!score.equals(that.score)) return false;
        if (!term.equals(that.term)) return false;

        return true;
    }

    public T getTerm() {
        return term;
    }

    public S getScore() {
        return score;
    }

    @Override
    public int hashCode() {
        int result = term.hashCode();
        result = 31 * result + score.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return String.format("%s:%s", term, score);
    }
}
